home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr44 / _xygraf.zip / MEMORY.TXT < prev    next >
Text File  |  1995-02-27  |  3KB  |  52 lines

  1. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2. ░░░░░░░░░░░░░░░░░░░░░░░ Memory control and debugging tools ░░░░░░░░░░░░░░░░░░
  3. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  4.  
  5. Memory errors are the most unpleasant. Debugger, IDE and program itself
  6. works in this situation in the same manner. They hang up the computer.
  7. KNOW-HOW contain the solution of this problem, really - two solutions.
  8.  
  9. First is the HCHECK.CPP (heap check) file. It works using #pragma directive,
  10. and does not require any modifications in your program. If you include it to
  11. project, it works, if not - it does not. After program termination this code
  12. outputs heap info:
  13. ▐ before: 6200, after: 1500
  14. This mean, that you have forget to call some destructor, free some memory
  15. close graphics or do something like that. "before" MUST be equial to "after".
  16. ▐ heapcheck: -1
  17. This line reports that you have destroy your heap, for example, call the
  18. destructor two times for the same structure. heapcheck MUST be 2.
  19.  
  20. Second tool is much more powerfull. It is FARHEAPD.LIB file (source codes
  21. included). To use it, for example, from IDE, you should include it to project,
  22. compile the program with debug information, then go to DOS Shell (Alt-F, D),
  23. switch on the printer, and type in DOS prompt line:
  24. ▐ >set debug=prn
  25. ▐ >program name
  26. The program will work in the usual manner, but printer will print all
  27. memory allocations, deallocations and results of these operations. Usint this
  28. listing you could find line, where result become <<heap error>> exept of
  29. <<OK>>.
  30. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  31. Taking into account that program could be extremely large, and listing - too,
  32. I include additional tool to interprete this listing (MINFO.EXE). Instead
  33. of endless listing like
  34. .......
  35. debugging C memory management:     malloc 7EA3:0004 for 80 bytes
  36. debugging C memory management:     malloc 7EA9:0004 for 80 bytes
  37. debugging C memory management:     malloc 7EAF:0004 for 4096 bytes
  38. debugging C memory management:     malloc 7FB0:0004 for 38 bytes
  39. debugging C memory management:     malloc 7FB3:0004 for 15 bytes
  40. debugging C memory management:     malloc 7FB5:0004 for 512 bytes
  41. debugging C memory management:       free 7FB5:0004
  42. debugging C memory management:     malloc 7FB5:0004 for 51 bytes
  43. debugging C memory management:     malloc 7FB9:0004 for 1 bytes
  44. debugging C memory management:     malloc 7FBA:0004 for 74 bytes
  45. .......... (total 1 Mbyte )
  46. user get:
  47. Level 1 >(  440) WARNING! Free without Malloc at pointer  0000:0000
  48. Level 1 >(  441) WARNING! Free without Malloc at pointer  0000:0000
  49. Level 1 >(  442) WARNING! Free without Malloc at pointer  0000:0000
  50. Level 1 >(  443) WARNING! Free without Malloc at pointer  0000:0000
  51. (total 4 lines)
  52.